import React from 'react';
import './index.less';
import render from 'src/hrpub/common/frame/render';
import {connect} from 'src/hrpub/common/store';
import Pagination from 'src/hrpub/common/components/Pagination';
import {
    base
} from 'nc-lightapp-front';
import TableAction from "./actions"
import {COMMON} from "../../../../unit/util";

const DetailTable = render({
    actions: {
        tableAct: TableAction
    }
})(({props, action}) => {
    const {staffCom, editTable, pageInfo} = props;
    let hidePage = [COMMON.pageAgeEdu,COMMON.pageEntryDimission,COMMON.pageRankStr,COMMON.pageStaffChange];
    let hideFlag = hidePage.includes(staffCom.page);
    let tableId = COMMON.tableIdObj[staffCom.page];
    if(staffCom.page === COMMON.pageSubdetail){
        tableId = staffCom.advObj.tableId;
    }

    const pageParam = {
        current: ~~pageInfo.pageIndex,//当前页面, 从 1 开始计算，如果传入了这个props，则组件视为可控组件
        defaultPageSize: pageInfo.pageSize,// 默认每页条数
        hideOnSinglePage: false,// 只有一页时是否隐藏分页器
        pageSize: pageInfo.pageSize,// 每页条数
        pageSizeOptions: [10, 50, 100, 150, 200],// 指定每页显示多少条
        showQuickJumper: false,// 是否可以快速跳转至某页
        showSizeChanger: true,// 是否可以改变pageSize
        showTotal: '',// 函数 用于展示有多少条
        total: pageInfo.total,// 数据总数
        onChange: action.tableAct.paginationEve,// 页码改变回调函数
        onShowSizeChange: action.tableAct.pageSizeSelect// pageSize改变的回调函数
    };
    return (
        <div className={'detail-table'}>
            <div className={'table-box'}>
                {editTable.createEditTable(tableId)}
            </div>
            <If condition={!hideFlag}>
                <div className={'pagination-component'}>
                    <Pagination
                        {...pageParam}
                    />
                </div>
            </If>
        </div>
    );

});

export default DetailTable;